package com.zxshhy.mqconfirmback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @author: zxs
 * @Date: 2018/11/7
 * @Description:
 */

@Slf4j
@Component
public class ReturnCallback implements RabbitTemplate.ReturnCallback {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setReturnCallback(this);
    }

    @Override
    public void returnedMessage(Message message, int param1, String param2, String exchangeName, String queueName) {
        log.info("MQ消息发送失败，返回回调信息：\nMessage={}\nparam1={}\nparam2={}\nexchangeName={}\nqueueName={}",message,param1,param2,exchangeName,queueName);
    }
}
